//
//  SureTradPwdViewController.m
//  WBBaseProject
//
//  Created by 吴斌 on 2018/3/12.
//  Copyright © 2018年 吴斌. All rights reserved.
//

#import "SureTradPwdViewController.h"
#import "TXTradePasswordView.h"
@interface SureTradPwdViewController ()<TXTradePasswordViewDelegate>

/** <#注释#> */
@property (nonatomic,strong) TXTradePasswordView *TXView;

@end

@implementation SureTradPwdViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title = @"确认交易密码";
    
    TXTradePasswordView *TXView = [[TXTradePasswordView alloc]initWithFrame:CGRectMake(0, 50,SCREEN_WIDTH, 200)];
    _TXView = TXView;
    TXView.isSurePws = YES;
    TXView.TXTradePasswordDelegate = self;
    if (![TXView.TF becomeFirstResponder])
    {
        //成为第一响应者。弹出键盘
        [TXView.TF becomeFirstResponder];
    }
    [self.view addSubview:TXView];
}

#pragma mark  密码输入结束后调用此方法
-(void)TXTradePasswordView:(TXTradePasswordView *)view WithPasswordString:(NSString *)Password
{
    WB_WeakSelf(self)
    NSLog(@"密码 = %@",Password);
    if (!WB_IsEquallString(Password, _tradPwd)) {
        _TXView.isError = YES;
    }else{
        if (_isAddPwd) {
            [XYHttpRequest dataRequestWithAddTraderPwd:Password success:^(id responseObj) {
                [NSObject wb_showAlertWithTitle:responseObj[@"info"] duration:1];
                if (Success) {
                    //延时1s返回
                    WB_DISPATCH_MAIN_Delay_THREAD(1, ^{
                        [weakself.navigationController popToRootViewControllerAnimated:YES];
                    })
                }
            } failure:^(NSError *error) {
            }];
        }else{
            [XYHttpRequest dataRequestWithChangeTraderPw:_oldPwd newPw:Password success:^(id responseObj) {
                [NSObject wb_showAlertWithTitle:responseObj[@"info"] duration:1];
                if (Success) {
                    //延时1s返回
                    WB_DISPATCH_MAIN_Delay_THREAD(1, ^{
                        [weakself.navigationController popToRootViewControllerAnimated:YES];
                    })
                }
            } failure:^(NSError *error) {
            }];
        }
    }
}


@end
